package td.pt.event;

import java.util.Set;

import td.domain.Thought;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;

public class ReferenceThoughtsEvent extends
		GwtEvent<ReferenceThoughtsEvent.ReferenceThoughtsHandler> {

	public static Type<ReferenceThoughtsHandler> TYPE = new Type<ReferenceThoughtsHandler>();
	private Set<Thought> thoughtsToReference;

	public interface ReferenceThoughtsHandler extends EventHandler {
		void onReferenceAThought(ReferenceThoughtsEvent event);
	}

	public interface ReferenceThoughtsHasHandlers extends HasHandlers {
		HandlerRegistration addReferenceAThoughtHandler(
				ReferenceThoughtsHandler handler);
	}

	public ReferenceThoughtsEvent(Set<Thought> thoughtsToReference) {
		this.thoughtsToReference = thoughtsToReference;
	}

	public Set<Thought> getThoughtsToReference() {
		return thoughtsToReference;
	}

	@Override
	protected void dispatch(ReferenceThoughtsHandler handler) {
		handler.onReferenceAThought(this);
	}

	@Override
	public Type<ReferenceThoughtsHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<ReferenceThoughtsHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, Set<Thought> thoughtToReferences) {
		source.fireEvent(new ReferenceThoughtsEvent(thoughtToReferences));
	}
}
